package com.ruoyi.extdata.service.impl;

import com.ruoyi.bizsys.domain.BankCode;
import com.ruoyi.bizsys.service.IBankCodeService;
import com.ruoyi.bizsys.utils.BizConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.extdata.service.IBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @Author: Jamnsin
 * @Date: 2021/7/26 1:30 下午
 */
@Service
public class BankServiceImpl implements IBankService {

    @Autowired
    IBankCodeService bankCodeService;

    @Override
    public String getBankCode(String bankName) {
        if (StringUtils.isBlank(bankName)) {
            return "";
        }
        String bankCode = "";

        BankCode bankCodeQ = new BankCode();
        bankCodeQ.setPaystackBankName(bankName);
        bankCodeQ.setState(BizConstants.BIZ_STATUS_1);
        List<BankCode> bankCodes = bankCodeService.selectBankCodeList(bankCodeQ);

        if (!CollectionUtils.isEmpty(bankCodes)) {
            bankCode = bankCodes.get(0).getPaystackBankCode();
        }
        return bankCode;
    }
}
